{include file="public/header"}
<style>

            #dwv_1{
                border-radius: 0.3rem;
                overflow: hidden;
                position: relative;
            }

        </style>
<body style="background-color: #f1f1f1;">
<div class="index_html  new_huanzhe_record add_jilu">

{include file="public/nav"}
 <form action="" class="horizontal" method="post" role="form" >

<div class="list_box">
    <div class="title">
        <p>新建患者记录</p>
    </div>
    <div class="content">
        <div class="msg">
            <ul>
                <li>
                    <span>检查编号：</span>
                    <div class="right">
                        <input type="text" name="case_num" placeholder="如：20151515">
                    </div>
                </li>
                <li class="name">
                    <span>姓名：</span>
                    <em>{$patientInfo['name']}</em>
                    <input type="hidden" value="{$patientInfo['id']}" name="patient_id">
                </li>
                <li>
                    <span>检查类型：</span>
                    <div class="right">

                        <select name="patient_case_type" >

                            {if condition="$case_select"}
                            {foreach name="case_select" item="vo"}
                            <option value="{$vo['id']}" >{$vo['name']}</option>
                            {/foreach}
                            {else/}
                            <option value="" disabled="">请选择</option>
                            {/if}

                        </select>
                    </div>
                </li>
                <li class="buwei">
                    <span>检查部位：</span>
                    <div class="right_box">
                        <div class="top">
                            <div class="li_1">
                                <div class="right">
                                    <select name=""  class="change_part">
                                      <!--  <option value="0" disabled="">请选择</option>-->
                                        {if condition="$case_depart"}

                                        {foreach name="case_depart" item="vo"}
                                        <option value="{$vo['name']}" >{$vo['name']}</option>
                                        {/foreach}


                                        {else/}

                                        <option value="" disabled="">请选择</option>
                                        {/if}
                                    </select>
                                </div>
                                <span class="weidu">维度：</span>
                                <div class="right right_2">
                                    <select name="" class="change_lat">
                                       <!-- <option value="0" disabled="">请选择</option>-->
                                        {if condition="$case_lat"}
                                        {foreach name="case_lat" item="vo"}
                                             <option value="{$vo['name']}" >{$vo['name']}</option>
                                        {/foreach}

                                        {else/}
                                            <option value="" disabled="">请选择</option>
                                        {/if}
                                    </select>
                                </div>


                                <div class="add_box">
                                    <span class="option_btn"></span>
                                </div>

                            </div>
                            <input type="hidden" name="patient_part_lat[1][lat]" class="patient_lat" value="{if condition='isset($case_lat[0]["name"])'}{$case_lat[0]['name']} {else/} ''{/if}">
                            <input type="hidden" name="patient_part_lat[1][part]" class="patient_part" value="{if condition='isset($case_depart[0]["name"])'}{$case_depart[0]['name']} {else/} ''{/if}">


                        </div>
                        <!-------第一个部位维度---------->

                         <!-------第一个部位维度---------->
                        <div class="li_s">

                        </div>
                    </div>

                </li>
                <li>
                    <span>检查时间：</span>
                    <div class="right">
                        <script type="text/javascript">
                            $(function(){
                                $('.end_date_picker').date_input();
                            })
                        </script>
                        <div style="" class="input_box">
                            <input  style="" type="text" class="end_date_picker" value="" name="check_time" id="new_date">
                        </div>
                        <script>
                            //创建一个当前日期对象
                            var now = new Date();
                            //格式化日，如果小于9，前面补0
                            var day = ("0" + now.getDate()).slice(-2);
                            //格式化月，如果小于9，前面补0
                            var month = ("0" + (now.getMonth() + 1)).slice(-2);
                            //拼装完整日期格式
                            var today = now.getFullYear()+"-"+(month)+"-"+(day) ;
                            //完成赋值
                            $('#new_date').val(today);
                        </script>
                    </div>
                </li>
                <li class="reslut">
                    <span>检查结果：</span>
                    <div class="right">
                        <textarea name="check_result" id="" cols="30" rows="10"></textarea>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <!--  列表的开始 -->
    <div class="list">
        <div class="data data_1">
            <p >电子报告</p>
            <div class="img_box" id="img_box">
                <div class="up_box" id="pic">
                    <div class="up_btn">
                        <span>上传照片</span>
                    </div>
                </div>
				
            </div>
        </div>
        <!-- 电子胶片的 开始-->
        <div class="data data_2 buwei_dec">
            <div class="tit_top">
                <p class="theme">电子胶片</p>
                <div class="tit_right">
                    <!-- 右面的 按钮 开始 -->
                    <a  class="add_btn">新建分组</a>
                    <a  class="cancle_btn">删除分组</a>
                </div>
            </div>


            <!-------------部位1----------------->
            <div class="pic_box" id="img_box_film_1">
                <span>部位： </span>
                <div class="mini_theme">
                    <input type="text" name="electronic_film[1][report_name]">
                </div>
                <em class="decrease_btn"></em>
                <div class="jiaopian_box">
                    <div class="up_box" id="electronic_film_1">
                        <div class="up_btn">
                            <span>上传照片</span>
                        </div>
                    </div>

                </div>


            </div>


            <script src="__STATIC__/common/webuploader/webuploader.min.js"></script>
            <script type="text/javascript" src="__STATIC__/common/dwv/dwv-0.22.0.min.js"></script>
            <script>

                //图片上传
                var uploader = WebUploader.create({
                    auto: true,
                    swf:'__ASSETS__/lib/webuploader/Uploader.swf',
                    server:'{:url("common/upload/uploadFile")}',
                    pick:'#electronic_film_1',
                    fileVal:'pic',
                    fileNumLimit:'5',
                    duplicate :true,
                    accept : {
                        title:"格式不正确",
                        extensions:"dcm"
                    }

                })

                uploader.on('uploadSuccess', function(file, response){
                    //console.log(response);
                    if (response.error == 0) {

                        //获取当前pic个数
                        var length = $(".pic_dec_1").length;

                        var html = '<div class="pic_dec_1"><div class="dcmDel"><img src="__STATIC__/index/imgs/dcmDel.png"/></div>';
                        html += ' <div id="dwv_1_'+length+'">';
                        html += ' <div class="layerContainer">';
                        html += ' <canvas class="imageLayer"></canvas>';
                        html += ' </div>';
                        html += ' </div>';
                        html += ' </div>';
                       html += '<input type="hidden" class="body_album" name="electronic_film[1][img][]" value="'+response.url+'"/>';
                        $('#img_box_film_1').append(html);
                        url = response.url;

						init_dicom(1,length,url)

                    }
                });

                uploader.on("error", function (type) {
                    if (type == "Q_TYPE_DENIED") {
                        layer.msg("请上传DCM格式文件");
                    }else {
                        layer.msg("上传出错！请检查后重新上传！错误代码"+type);
                    }

                });
                //删除图片
                $('body').on('click', '.remove-img', function(){
                    $(this).parent().remove();
                    uploader.trigger('fileDequeued');
                })

				/* 删除上传的dcm文件 */
				$("body").on("click",".dcmDel",function(){
					$(this).parent().next().remove();
					$(this).parent().remove();
				})
            </script>

            <!------------部位1------------------>
        </div>
        <!-- 电子胶片的 结束-->

        <!-- 录入医生 -->
        <div class="enter_doctor">
            <p>录入医生：<span>{$doctor['name']}</span></p>
            <input type="hidden" name="doctor_id" value="{$doctor['id']}" />
        </div>

    </div>
    <!--  列表的开始 -->



    <div class="save_or_no">
        <a  class="cirtain">
            <input type="button" class="ajax-post" value="确定">
        </a>
        <a href="javascript:history.back(-1)">
            取消
        </a>
    </div>
</div>
    </form>
</div>
<script>
    $(function(){


        $(document).on("mouseenter",".new_huanzhe_record .list_box .list .pic_dec",function(){
            $(this).find("em").show();
        });
        $(document).on("mouseleave",".new_huanzhe_record .list_box .list .pic_dec",function(){
            $(this).find("em").hide();
        });
    })
</script>
<!-----获取经纬度的个数--->
<input type="hidden" value="1" name="add_case_depart_lat">
<!-----电子胶片--->
<input type="hidden" value="1" name="add_record_depart_value">
<input type="hidden" value="{$case_lat[0]['name'] ?? ''}" name="default_lat">
<input type="hidden" value="{$case_depart[0]['name'] ??''}" name="default_part">


{include file="public/footer"}

<script>
        $(document).on("click","a.add_btn",function(){

            //获取pic_box的长度,添加id
            var num = $(".buwei_dec .pic_box").length;
			
            $.ajax(
                    {
                        url : "{:url('record/add_record_depart')}",
                        type : 'post',
                        data: {"num":num},
                        dataType : 'json',
                        success : function (result)
                        {
                            console.log(result)

                            $(".buwei_dec").append(result);
                            var value_num = Number(num+1);
                            console.log(value_num);
                            $("[name=add_record_depart_value]").val(value_num);
                    }


        })
        })
        

</script>

<script src="__STATIC__/common/webuploader/webuploader.min.js"></script>
<script>
    //图片上传
    var uploader = WebUploader.create({
        auto: true,
        swf:'__ASSETS__/lib/webuploader/Uploader.swf',
        server:'{:url("common/upload/uploadFile")}',
        pick:'#pic',
        fileVal:'pic',
        fileNumLimit:'3',
        duplicate :true

    })

    uploader.on('uploadSuccess', function(file, response){
        //console.log(response);
        if (response.error == 0) {
            var html = '<div class="pic_dec">';
            html += '<img src="'+response.url+'"/>';
            html += '<input type="hidden" class="body_album" name="electronic_report[]" value="'+response.url+'"/>';
            html += '<em class="remove-img"></em>';
            html += '</div>'
            $('#img_box').append(html);
        }
    });


    uploader.on( 'uploadError', function( file ) {
        console.log(file);
    });

    //删除图片
    $('body').on('click', '.remove-img', function(){
        $(this).parent().remove();
        uploader.trigger('fileDequeued');
    })

</script>

